package com.easy.common.enumbean;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;

public enum ContactType {
    // 手机 ,工作电话,传真,微信,其他
    PHONE("手机"), WORKTEL("工作电话"), FAX("传真"), WECHAT("微信"), OTHER("其他");
    @EnumValue
    private String value;

    private ContactType(String value) {
        this.value = value;
    }

    @JsonCreator
    public ContactType convert(String val) {
        switch (val) {
            case "手机":
                return PHONE;
            case "工作电话":
                return WORKTEL;
            case "微信":
                return WECHAT;
            case "传真":
                return FAX;
            case "其他":
                return OTHER;
            default:
                throw new RuntimeException("没有对应的枚举实例");
        }
    }

    public String valueOf() {
        return this.value;
    }

    public String toString() {
        return this.value;
    }
}
